package cn.yoyo.controller.adm;

import cn.yoyo.service.BlogService;
import cn.yoyo.tools.RespJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/api/adm/blog")
public class AdmBlogController {
    @Autowired
    BlogService blogService;

    @RequestMapping("/go2AwatingBlogs")
    public String go2AwatingBlogs(){
        return "blog/awatingBlogs";
    }

    @RequestMapping("/findAll")
    @ResponseBody
    public Map<String,Object> findAll(){
        return RespJson.pack(200,"",blogService.findAllCantSee());
    }

    @RequestMapping("/pass/{blogId}")
    @ResponseBody
    public Map<String,Object> pass(@PathVariable("blogId") String blogId){
        blogService.isPass(blogId);
        return RespJson.pack(200,"",blogService.findAllCantSee());
    }

    @RequestMapping("/noPass/{blogId}")
    @ResponseBody
    public Map<String,Object> noPass(@PathVariable("blogId") String blogId){
        blogService.noPass(blogId);
        return RespJson.pack(200,"",blogService.findAllCantSee());
    }

}
